package com.lean.android.ad.utils

import android.content.Context
import com.lean.android.ad.core.AdSdk
import com.umeng.analytics.MobclickAgent
import com.umeng.commonsdk.UMConfigure

object UmengHelper {

    fun onEvent(context: Context, action: String) {
        if (UMConfigure.isInit) return
        MobclickAgent.onEvent(context, action, AdSdk.getAdConfig().channelInfoProvider.getChannel())
    }

    fun init(context: Context) {
        if (UMConfigure.isInit) return
        AdLog.d(AdLog.AdInitTag, "init umeng sdk.")
        UMConfigure.init(
            context,
            AdSdk.getAdConfig().umengAppKey,
            AdSdk.getAdConfig().channelInfoProvider.getChannel(),
            UMConfigure.DEVICE_TYPE_PHONE,
            ""
        )
        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO)
        AdLog.d(AdLog.AdInitTag, "umeng sdk init success.")
    }

}